package com.bitauto.i.commonUtils.controller;

import com.bitauto.i.commonUtils.model.ProductVO;
import com.bitauto.i.commonUtils.model.Result;
import com.bitauto.i.commonUtils.service.ProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ProductService productService;

    @GetMapping("/check")
    public Result check() {
        ProductVO productVO=productService.createProduct();
        Result check = productService.createCheck(productVO);
        return check;
    }

    public static void main(String[] args) {
        /*String name = "修改用户名.xlsx";
        String[] arr=name.split("\\.");
        System.out.println(arr[0]);
        System.out.println(arr[1]);*/
        int[] nums = new int[]{2,7,11,15};
        int target = 9;
        twoSum(nums,target);
    }

    public static int[] twoSum(int[] nums, int target) {
        Map<Integer,Integer> map=new HashMap<Integer,Integer>();
        int[] arr =new int[2];
        for(int i=0;i<nums.length;i++){
            if (map.containsKey(target - nums[i])) {
                arr[0]=map.get(target - nums[i]);
                arr[1]=i;
                return arr;
            }
            map.put(nums[i], i);
        }
        return arr;
    }



}
